import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

//配置进度条(去除looding动画)

NProgress.configure( { showSpinner: false});

Vue.use(VueRouter)

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

//路由守卫
router.beforeEach((to,from,next)=>{
  document.title = to.meta && to.meta.title || '饿了么';
  next();
  NProgress.start();
})
router.afterEach((to,from)=>{
  NProgress.done();
})
export default router
